<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<#include "lib/lib.html" />
<title>添加卡</title>
</head>
<body>
	<form action="${basePath}/memberInfo/add.do" method="post" class="form form-horizontal" id="form">
	<div class="pop_main" style="padding-left:30px;width: 95%;">
		<div class="panel panel-primary mt-20">
	    	<div class="panel-header">卡信息</div>
	    	<div class="panel-body">
	    		<table class="table table-border table-bordered table-hover table-bg table-sort">
					<tbody>
						<tr>
	    		    		<td style="width:120px;"><strong>卡名称：</strong></td>
	    		    		<td>
	    		    			<input style="width:300px;" class="dd_input input-text size-M" type="text" placeholder="请输入卡名称" id="memberName" name="memberName" datatype="*"  nullmsg="请输入卡名称" >
	    		    		</td>
	    		    	</tr>
	    		    	<tr>
	    		    		<td style="width:120px;"><strong>宣传图片：</strong></td>
	    		    		<td>
								<input style="width:300px;" readonly="readonly" type="text" class="width200 input-text size-M"  dataType="*" nullmsg="上传宣传图片" name="imgUrl" id="imgUrl"/>
								<input type="file" class="width150 fileInputClass" name="file" id="imgUrlFile" onchange="uploadFile('${basePath}/upload/addFiles.do','imgUrl','File')"/>
	    		    		</td>
	    		    	</tr>
	    		    	<tr>
	    		    		<td style="width:120px;"><strong>价格（元）：</strong></td>
	    		    		<td>
	    		    			<input style="width:300px;" class="dd_input input-text size-M" type="text" placeholder="请输入价格" id="amount" name="amount" datatype="*"  nullmsg="请输入价格" >
	    		    		</td>
	    		    	</tr>
	    		    	<tr>
	    		    		<td style="width:120px;"><strong>卡类型：</strong></td>
	    		    		<td>
	    		    			<select style="width:300px;height: 30px;" onchange="typeChange();" class="select size-M" id="type" name="type" size="1">
									<option value="2">普通卡</option> 
									<option value="1">年卡</option> 
								</select>
	    		    		</td>
	    		    	</tr>
	    		    	<tr class="count">
	    		    		<td style="width:120px;"><strong>次数：</strong></td>
	    		    		<td>
	    		    			<input style="width:300px;" class="dd_input input-text size-M" type="text" placeholder="请输入次数" id="count" name="count" datatype="n"  nullmsg="请输入次数" >
	    		    		</td>
	    		    	</tr>
	    		    	<tr>
	    		    		<td style="width:120px;"><strong>有效月数：</strong></td>
	    		    		<td>
	    		    			<input style="width:300px;" class="dd_input input-text size-M" type="text" placeholder="请输入有效月数" id="validMonth" name="validMonth" datatype="n"  nullmsg="请输入有效月数" >
	    		    		</td>
	    		    	</tr>
	    		    	<tr>
	    		    		<td style="width:120px;"><strong>使用规则：</strong></td>
	    		    		<td>
	    		    			<textarea style="width:500px;height:300px;" class="input-text size-M" placeholder="使用规则" id="remark" name="remark"></textarea>
	    		    		</td>
	    		    	</tr>
    		    	</tbody>
			    </table>
	    	</div>
    	</div>
    	
		<div class="submit_btn">
			<button style="width:100px;height:40px;" type="button" name="" value="提    交" onclick="submitButt()" class="btn btn-warning radius"><i class="Hui-iconfont">&#xe676;</i> 提    交</button>
		</div>
	</div>
	</form>
<script type="text/javascript">
		$(function(){
			$("#form").Validform({
				tiptype:3,
				showAllError:true,   //表单提交时显示所有提示信息
				ignoreHidden: true,  //隐藏的表单元素不校验
				ajaxPost:true,
				callback:function(data){
					$.Hidemsg();
					if(data.resultCode==200){
						layer.msg('保存成功!', {
							icon : 1,
							time : 1000
						});
						//parent.location.replace("${basePath}/payv2PayWayRate/payv2PayWayRateListAll.do?payWayId="+$("#payViewType").val());
						setTimeout(function () { 
					        layer_close();
					    }, 1000);
					}else{
						$("#form").resetForm();
						layer.msg('保存失败，请你检查数据!', {
							icon : 1,
							time : 1000
						});
					}
				}
			});
		});
		
		function uploadFile(url,idstr,filestr) {
			if($("input[id='"+idstr+filestr+"']").val()==""){
  	            layer.msg('请选择上传文件！', function(){});
				return;
			}
			commonUp(url, $("input[id='"+idstr+filestr+"']"), function(data) {
					$("#"+idstr).val(data.Data.url);
			});
	
		}
		
		//无刷新上传文件
		function commonUp(url, e, callback) {
			$.ajaxFileUpload({
				url : url,
				secureuri : false,
				fileElement : e,
				dataType : "JSON",//返回数据的类型
				success : function(data,status) {
					if (data.resultCode == 200) {
						if (callback) {
							callback(data);
						}
					} else {
						//alert("上传失败！");
						alert(data.Data);
					}
					
				}
			});
		}
		
		$(document).ready(function(){
			$('select').searchableSelect();
		});

		function submitButt(){
			$("#form").attr(
					"action",
					"${basePath}/memberInfo/add.do").submit(); 
		}

		//验证输入的数字合法性
		function ValidateFloat(e, pnumber){ 
			if (!/^\d+[.]?\d*$/.test(pnumber)){ 
				$(e).val(/^\d+[.]?\d*/.exec($(e).val())); 
			}
			return false; 
		}
		
		function typeChange(){
			var type = $("#type").val();
			if(type==2){
				$(".count").show();
				$("#count").val("");
				$("#validMonth").val("");
				$("#validMonth").removeAttr("readonly");
			}else{
				$(".count").hide();
				$("#validMonth").val("12");
				$("#validMonth").attr("readonly","readonly");
			}
		}
		
</script>
</body>
</html>